#include"process.h"
void process()
{
  int i = 0;
  char bar[102];
  memset(bar,0,sizeof(bar));
  const char * lable="|/-\\";
  int len = strlen(lable);
  while( i<= 100 )
  {
    printf("[%-100s][%d%%][%c]\r",bar,i,lable[i%len]);
    fflush(stdout);
    bar[i++]='#';
    usleep(10000);
  }
 printf("\n"); 
}

void _process(int sum , int current)
{
  int i = ((double)current/sum)*100;
  if(i>100)i=100;
  char bar[102];
  memset(bar,0,sizeof(bar));
  const char * lable="|/-\\";
  int len = strlen(lable);
 for(int j=0;j < i;j++)
 {
   bar[j]='#';
 }

    printf("[%-100s][%d%%][%c]\r",bar,i,lable[i%len]);
    fflush(stdout);
  
}
void Download()
{
  int sum = 1024;
  int current = 0;
  while(current <= 1024)
  {
    _process(sum,current);// 这里没有传递参数
    current+=20;
    usleep(10000);
  }
  _process(sum,current);
}
